package org.huzhp.console.core;

import java.util.Objects;
import java.util.function.Consumer;

/**
 * @Description: java类作用描述
 * @Author: huzp
 * @CreateDate: 2020/3/12 21:12
 * @Version: 1.0
 */
public interface Attempt {

    static <T> Consumer<T> apply(ConsumerCheckedFunction<T> function) {
        Objects.requireNonNull(function);

        return (T t) -> {
            try {
                function.apply(t);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        };
    }

}